﻿CREATE TABLE [CO].[Countries] (
    [Id]        INT           NOT NULL,
    [Name]      VARCHAR (100) NOT NULL,
    [ShortName] VARCHAR (20)  NOT NULL,
    [Note]      VARCHAR (250) NULL,
    [MD]        DATETIME      CONSTRAINT [DF__Countries__MD__7E37BEF6] DEFAULT (getdate()) NOT NULL,
    [MW]        VARCHAR (50)  CONSTRAINT [DF__Countries__MW__7F2BE32F] DEFAULT (suser_sname()) NOT NULL,
    [ToDelete]  BIT           DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_Countries] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
CREATE NONCLUSTERED INDEX [IX_Countries_Name]
    ON [CO].[Countries]([Name] ASC);


GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Countries_ShortName]
    ON [CO].[Countries]([ShortName] ASC);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Дата и время изменения строки', @level0type = N'SCHEMA', @level0name = N'CO', @level1type = N'TABLE', @level1name = N'Countries', @level2type = N'COLUMN', @level2name = N'MD';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Пользователь, последний раз изменивший строку', @level0type = N'SCHEMA', @level0name = N'CO', @level1type = N'TABLE', @level1name = N'Countries', @level2type = N'COLUMN', @level2name = N'MW';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Признак того, что запись нужно удалить из БД всех подразделений', @level0type = N'SCHEMA', @level0name = N'CO', @level1type = N'TABLE', @level1name = N'Countries', @level2type = N'COLUMN', @level2name = N'ToDelete';

